// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   OrderCancelAction.java

package com.boci.clientapp.orderstatus.action;

import com.boci.clientapp.main.ApplicationService;
import com.boci.clientapp.main.MainPanel;
import com.boci.clientapp.orderstatus.OrderCancelConfirmScrPanel;
import com.boci.clientapp.orderstatus.OrderStatusScrPanel;
import com.boci.clientapp.orderstatus.handler.OrderCancelHandler;
import com.boci.clientapp.orderstatus.vo.*;
import com.boci.common.action.AbstractAction;
import com.boci.common.constant.RequestTypeConst;
import com.boci.common.ui.AbstractTabSclPane;
import com.boci.common.util.AppException;
import com.boci.common.util.StringUtil;
import com.boci.common.vo.ResponseVO;
import java.util.Date;
import java.util.HashMap;
import java.util.logging.Logger;

public class OrderCancelAction extends AbstractAction
{

    public OrderCancelAction()
    {
        strModName = "ORDER_STATUS_MODULE";
    }

    public void doProcess(HashMap pInpMap, String pActionType)
    {
    	try{
	        appServ.setBusy(true);
	        if(pActionType.equals("CANCEL_REVIEW_CONFIRM"))
	            doOrderCancel(pInpMap);
	        else
	        if(pActionType.equals("CANCEL_REVIEW_NO"))
	        {
	            String strOrderStatusScr = "ORDER_STATUS_SCREEN";
	            appServ.getMainPanel().showScreen(strModName, strOrderStatusScr, false);
	        } else
	        if(pActionType.equals("CANCEL_REVIEW_OK"))
	        {
	            String strOrderStatusScr = "ORDER_STATUS_SCREEN";
	            OrderStatusScrPanel orderStatusPanel = (OrderStatusScrPanel)appServ.getMainPanel().getTab(strModName).getPanel(strOrderStatusScr);
	            int intLastSelection = orderStatusPanel.getSelection();
	            appServ.getMainPanel().showScreen(strModName, strOrderStatusScr);
	            orderStatusPanel.showOrderStatusTable(intLastSelection);
	        }
    	}
    	catch(AppException appEx)
        {
            appServ.showErrorDialog(null, appEx.getMessage());
        }
        catch(Exception sysEx)
        {
            logger.severe(StringUtil.formatException(sysEx));
            appServ.showSysErrDialog();
        }
        finally
        {
            appServ.setBusy(false);
        }
        return;
    }

    private void doOrderCancel(HashMap pInpMap)
        throws Exception
    {
        String strReqType = RequestTypeConst.BOCI_ORDER_CANCEL_URL;
        String strOrderCancelConfirmScr = "ORDER_STATUS_CANCEL_CONFIRM";
        String strOrderStatusScr = "ORDER_STATUS_SCREEN";
        ResponseVO responseVO = (ResponseVO)pInpMap.get("SELECTED_VO");
        if(responseVO == null)
            return;
        OrderStatusDetailVO orderStatusDetailVO = null;
        OrderDetailVO orderDetailVO = null;
        if(responseVO instanceof OrderStatusDetailVO)
            orderStatusDetailVO = (OrderStatusDetailVO)responseVO;
        else
        if(responseVO instanceof OrderDetailVO)
            orderDetailVO = (OrderDetailVO)responseVO;
        else
            return;
        if(orderDetailVO != null)
        {
            HashMap inHashMap = new HashMap();
            inHashMap.put("orderId", orderDetailVO.getOrderId());
            inHashMap.put("str", "CONFIRM");
            OrderCancelHandler orderCancelHandler = new OrderCancelHandler(strReqType);
            OrderCancelVO orderCancelVO = (OrderCancelVO)orderCancelHandler.getOrderCancel(inHashMap);
            pInpMap.put("ORDER_CANCEL_VO", orderCancelVO);
            appServ.getMainPanel().showScreen(strModName, strOrderCancelConfirmScr);
            OrderCancelConfirmScrPanel orderCancelConfirmScrPanel = (OrderCancelConfirmScrPanel)appServ.getMainPanel().getPanel(strModName, strOrderCancelConfirmScr);
            OrderStatusScrPanel orderStatusScrPanel = (OrderStatusScrPanel)appServ.getMainPanel().getPanel("ORDER_STATUS_MODULE", "ORDER_STATUS_SCREEN");
            if(orderStatusScrPanel != null)
                orderStatusScrPanel.setLastUpdateDateTime(new Date());
            orderCancelConfirmScrPanel.refresh(pInpMap);
        } else
        if(orderStatusDetailVO != null)
        {
            HashMap inHashMap = new HashMap();
            inHashMap.put("orderId", orderStatusDetailVO.getOrderId());
            inHashMap.put("str", "CONFIRM");
            OrderCancelHandler orderCancelHandler = new OrderCancelHandler(strReqType);
            OrderCancelVO orderCancelVO = (OrderCancelVO)orderCancelHandler.getOrderCancel(inHashMap);
            pInpMap.put("ORDER_CANCEL_VO", orderCancelVO);
            appServ.getMainPanel().showScreen(strModName, strOrderCancelConfirmScr);
            OrderCancelConfirmScrPanel orderCancelConfirmScrPanel = (OrderCancelConfirmScrPanel)appServ.getMainPanel().getPanel(strModName, strOrderCancelConfirmScr);
            OrderStatusScrPanel orderStatusScrPanel = (OrderStatusScrPanel)appServ.getMainPanel().getPanel(strModName, strOrderStatusScr);
            orderStatusScrPanel.setLastUpdateDateTime(new Date());
            orderStatusScrPanel.updateAllLastUpdateTime();
            orderCancelConfirmScrPanel.refresh(pInpMap);
        }
    }

    String strModName;
}
